package com.kevin.ms.controller;

import com.kevin.ms.domain.User;
import com.kevin.ms.result.Result;
import com.kevin.ms.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;


    @PostMapping("/add")
    public Result add(User user) {
        userService.save(user);
        return Result.success();
    }

    @GetMapping("/list")
    public Result list() {
        return Result.success(userService.list());
    }
}
